import { TimeManager } from './../utils/timeManager';
import { MessageBoxService, IMessageBoxContainer } from './../components/messageBox';
import { FNCManager } from './../utils/fnc/fncManager';
import { Order } from './../models/order';
import { List } from 'immutable';
import { OrderSvr, ServiceBaseX } from './../services/order';
import { ConfigSvr } from './../services/config';
import { defaultKdsConfig } from './../../config';
import { MessageHandleManager } from './../utils/messageHandle/messageHandleManager';
class MessageUtil {
    handlers: Array<any> = [];
    mock() {
        this.handlers = [];
        spyOn(FNCManager.prototype, 'Connect').and.returnValue(Promise.resolve({
        RegistMessageHandler:()=>{}
        }));
        spyOn(MessageHandleManager.prototype, 'GetMessageHanle').and.callFake(() => {
            var handler = {};
            this.handlers.push(handler);
            return handler;
        });
        spyOn(OrderSvr.prototype, 'getOrders').and.returnValue(Promise.resolve(List<Order>()));
        spyOn(OrderSvr.prototype, 'getFinishedOrdersByStall').and.returnValue(Promise.resolve(List<Order>()));
        OrderSvr.prototype.currentKitchenSolutions = [{id:'stall1'}];
        // OrderSvr.prototype.kitchenSolution = {id:'stall1'};
        ServiceBaseX.prototype.LDCConfig = {ip:''}
        ConfigSvr.prototype.kdsConfig = defaultKdsConfig

        spyOn(ServiceBaseX.prototype, 'getServerTime').and.callFake(()=>Promise.resolve({serverTime:new Date().getTime()}))
        MessageBoxService.current.Regist({} as IMessageBoxContainer);
    }
    sendMessage(message) {
        this.handlers.forEach(handler=>handler.OnMessage(message));
    }
}
export const messageUtil = new MessageUtil();
